package main;

import dao.NewsDao;
import factory.AbstractFactory;
import factory.SimpleDaoFactory;
import factory.impl.MySqlDaoFactory;
import org.junit.jupiter.api.Test;
import pojo.News;
import service.NewsService;
import service.impl.NewsServiceImpl;

public class NewsServiceImplTest {
    @Test
    public void addNews() throws Exception{
//       NewsDao dao = SimpleDaoFactory.getInstance("mysql");
        AbstractFactory factory = new MySqlDaoFactory();
        NewsDao dao = factory.getInstance();
        NewsServiceImpl service = new NewsServiceImpl();
        service.setDao(dao);

        News news = new News();
        news.setNtitle("测试2");
        news.setNcontent("测试内容2");
        service.addNews(news);
    }
}
